import {getAllDict} from "@/api/homeApi";

const state = {
    commonDict: [],
    isHaveServiceCompanyInfo: false,
    uploadUrl: '/file/v1/upload'
}
const mutations = {
    SET_DICT: (state, dict) => {
        state.commonDict = {...dict}
    },
    SET_ISHAVESERVICECOMPANYINFO: (state, isHave) => {
        state.isHaveServiceCompanyInfo = isHave
    }
}
const actions = {
    getCommonDict({commit, state}) {
        return new Promise((resolve, reject) => {
            getAllDict().then(res => {
                if (res.code === 200) {
                    commit('SET_DICT', res.data)
                    resolve(res.data)
                } else {
                    resolve({})
                }
            }).catch(error => {
                reject(error)
            })
        })
    }
}
export default {
    actions,
    mutations,
    state
}
